<?php 
	$javascript->link( array( 'jquery/jquery-1-6-4', 'schedules/create' ), false );
?>

<h1>Mi Calendario</h1>

<p class="marginT marginB" >
	Defina aqui todas las actividades que usted realiza en su dia a dia, con el fin de que nuestro sistema sea capaz de determinar su tiempo libre y tiempo de trabajo
</p>

<?php 
	echo $form->create( 'Schedule', array( 'action' => 'index' ) );
		
		echo '<a href="#" id="addOtherActivity">Agregar Otra Actividad</a>';
		
		echo '<div class="clear"></div>';
			
		if( empty( $this->data ) ){
			echo '<div class="schedule" >';
				
				echo "<a href='#' style='display:none;' class='removeSchedule'>Remover</a>";
				
				echo $form->input( 'Schedule.1.name', array( 'class' => 'scheduleName', 'label' => 'Nombre de Actividad' ) );
				echo $form->input( 'Schedule.1.description', array( 'class' => 'scheduleDescription',  'label' => 'Descripcion' ) );

				echo '<div class="daySelector">';
				echo	'<p><b>Horario</b></p>';
					
					echo $form->input( 'Schedule.1.monday', array( 'class' => 'scheduleMonday', 'type' => 'checkbox', 'label' => 'L' ) );
					echo $form->input( 'Schedule.1.tuesday', array( 'class' => 'scheduleTuesday', 'type' => 'checkbox', 'label' => 'Ma' ) );
					echo $form->input( 'Schedule.1.wednesday', array( 'class' => 'scheduleWednesday', 'type' => 'checkbox', 'label' => 'Mi' ) );
					echo $form->input( 'Schedule.1.thursday', array( 'class' => 'scheduleThursday', 'type' => 'checkbox', 'label' => 'J' ) );
					echo $form->input( 'Schedule.1.friday', array( 'class' => 'scheduleFriday', 'type' => 'checkbox', 'label' => 'V' ) );
					echo $form->input( 'Schedule.1.saturday', array( 'class' => 'scheduleSaturday', 'type' => 'checkbox', 'label' => 'S' ) );
					echo $form->input( 'Schedule.1.sunday', array( 'class' => 'scheduleSunday', 'type' => 'checkbox', 'label' => 'D' ) );

					echo '<div class="floatL">';
						echo 'Desde: ';
						echo $form->select( 'Schedule.1.start_time_hour', array( '01','02','03','04','05','06','07','08','09',10,11,12,13,14,15,16,17,18,19,20,21,22,23,'00' ),  11, array( 'class' => 'scheduleStartTimeHour' ) );
						echo '-';
						echo $form->select( 'Schedule.1.start_time_minute', array( '00','01','02','03','04','05','06','07','08','09',10,11,12,13,14,15,16,17,18,19,20,21,22,23, 24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60 ), 0, array( 'class' => 'scheduleStartTimeMinute' ) );
					echo '</div>';
						
					echo '<div class="marginL floatL">';
						echo 'Hasta: ';
						echo $form->select( 'Schedule.1.end_time_hour', array( '01','02','03','04','05','06','07','08','09',10,11,12,13,14,15,16,17,18,19,20,21,22,23,'00' ),  11, array( 'class' => 'scheduleEndTimeHour' ) );
						echo '-';
						echo $form->select( 'Schedule.1.end_time_minute', array( '00','01','02','03','04','05','06','07','08','09',10,11,12,13,14,15,16,17,18,19,20,21,22,23, 24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60 ), 0, array( 'class' => 'scheduleEndTimeMinute' ) );
					echo '</div>';
				
					
				echo '</div>';
				
				echo '<div class="clear"></div>';
			
				echo $form->input( "Schedule.1.is_bussy", array( 'type' => 'checkbox', 'label' => 'No disponible durante esta actividad', 'class' => 'scheduleIsBussy', 'checked' => 'checked' ) );
			
			echo '</div>';
			} else{
				foreach( $this->data as $listSchedule ){
					echo '<div class="schedule" >';
					
						
						$intScheduleId = $listSchedule['Schedule']['id'];
				
						echo "<a href='#' style='display:none;' class='removeSchedule'>Remover</a>";
						echo $html->link( 'Eliminar', array( 'action' => 'delete', $intScheduleId ), array( 'class' => 'deleteSchedule' ), null, null, 'Esta seguro de que desea eliminar esta actividad ?' );
							
						
					
						echo $form->input( "Schedule.{$intScheduleId}.id", array( 'value' => $intScheduleId ) );
						echo $form->input( "Schedule.{$intScheduleId}.name", array( 'value' => $listSchedule['Schedule']['name'], 'class' => 'scheduleName', 'label' => 'Nombre de Actividad' ) );
						echo $form->input( "Schedule.{$intScheduleId}.description", array( 'value' => $listSchedule['Schedule']['description'], 'class' => 'scheduleDescription',  'label' => 'Descripcion' ) );

						echo '<div class="daySelector">';
							echo	'<p><b>Horario</b></p>';
							
							$listTime = json_decode( $listSchedule['Schedule']['time'] );
										
							echo $form->input( "Schedule.{$intScheduleId}.monday", array( 'checked' => $listTime->monday == 1,  'class' => 'scheduleMonday', 'type' => 'checkbox', 'label' => 'L' ) );
							echo $form->input( "Schedule.{$intScheduleId}.tuesday", array( 'checked' => $listTime->tuesday == 1, 'class' => 'scheduleTuesday', 'type' => 'checkbox', 'label' => 'Ma' ) );
							echo $form->input( "Schedule.{$intScheduleId}.wednesday", array( 'checked' => $listTime->wednesday == 1, 'class' => 'scheduleWednesday', 'type' => 'checkbox', 'label' => 'Mi' ) );
							echo $form->input( "Schedule.{$intScheduleId}.thursday", array( 'checked' => $listTime->thursday == 1, 'class' => 'scheduleThursday', 'type' => 'checkbox', 'label' => 'J' ) );
							echo $form->input( "Schedule.{$intScheduleId}.friday", array( 'checked' => $listTime->friday == 1, 'class' => 'scheduleFriday', 'type' => 'checkbox', 'label' => 'V' ) );
							echo $form->input( "Schedule.{$intScheduleId}.saturday", array( 'checked' => $listTime->saturday == 1, 'class' => 'scheduleSaturday', 'type' => 'checkbox', 'label' => 'S' ) );
							echo $form->input( "Schedule.{$intScheduleId}.sunday", array( 'checked' => $listTime->sunday == 1, 'class' => 'scheduleSunday', 'type' => 'checkbox', 'label' => 'D' ) );

							echo '<div class="floatL">';
								echo 'Desde: ';
								echo $form->select( "Schedule.{$intScheduleId}.start_time_hour", array( '01','02','03','04','05','06','07','08','09',10,11,12,13,14,15,16,17,18,19,20,21,22,23,'00' ),  $listTime->start_time_hour, array( 'class' => 'scheduleStartTimeHour' ) );
								echo '-';
								echo $form->select( "Schedule.{$intScheduleId}.start_time_minute", array( '00','01','02','03','04','05','06','07','08','09',10,11,12,13,14,15,16,17,18,19,20,21,22,23, 24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60 ), $listTime->start_time_minute, array( 'class' => 'scheduleStartTimeMinute' ) );
							echo '</div>';
								
							echo '<div class="marginL floatL">';
								echo 'Hasta: ';
								echo $form->select( "Schedule.{$intScheduleId}.end_time_hour", array( '01','02','03','04','05','06','07','08','09',10,11,12,13,14,15,16,17,18,19,20,21,22,23,'00' ),  $listTime->end_time_hour, array( 'class' => 'scheduleEndTimeHour' ) );
								echo '-';
								echo $form->select( "Schedule.{$intScheduleId}.end_time_minute", array( '00','01','02','03','04','05','06','07','08','09',10,11,12,13,14,15,16,17,18,19,20,21,22,23, 24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60 ), $listTime->end_time_minute, array( 'class' => 'scheduleEndTimeMinute' ) );
							echo '</div>';
						
							
						echo '</div>';
						
						echo '<div class="clear"></div>';
			
						echo $form->input( "Schedule.{$intScheduleId}.is_bussy", array( 'checked' => $listSchedule['Schedule']['is_bussy'],  'type' => 'checkbox', 'label' => 'No disponible durante esta actividad', 'class' => 'scheduleIsBussy', 'checked' => 'checked' ) );
					
					echo '</div>';
				}
			}
					
			
		
		echo '<div class="clear"></div>';
		
		echo '<a href="#" id="addOtherActivity">Agregar Otra Actividad</a>';
		
	echo $form->end( 'Salvar' );
?>